home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor2 / num.exe / NUM.DOC
Text File  |  1993-12-11  |  56KB  |  1,557 lines

  1. (Comp.sys.hp48) Option:
  2. Item: 1224 by colbach@nessie.cs.id.ethz.ch [Philippe Colbach]
  3. Subj: NUMERICAL LIBRARY (v1.2)
  4. Date: 29 Jun 1993
  5.  
  6. NUMERICAL LIBRARY
  7. =================
  8.  
  9. Title: NUM
  10. ROMID: 962
  11. Bytes: 20593
  12. CHKSM: # 4245h
  13.  
  14. ERRATUM  (documentation follows)
  15. =======
  16.  
  17. - I didn't mentioned in the documentation below that <derFcn> must have
  18.   2 arguments <F(X)> and <Fx(X)> (or <1>)
  19.   ^^^^^^^^^^^
  20. Combining [IPOL] with [SOLV], [SYST] and [INTG]:
  21.  
  22.  
  23.                         | [SOLV]        | [SYST]        | [INTG]
  24. ----------------------------------------------------------------------
  25. Interpolation <Fcn>     | predefined    | predefined    | predefined
  26.                         |               |               |
  27. Derivative <derFcn>     | predefined    | UNDEFINED     | predefined
  28.                         |               | ^^^^^^^^^     |
  29. Argument of <Fcn>       | F(X)          | F(X,Y)        | F(X)
  30.                         |               | ^^^^^^        |
  31. Arguments of <derFcn>   | F(X) & Fx(X)  | UNDEFINED     | F(X) & Fx(X)
  32.                         | F(X) & 1      | ^^^^^^^^^     | F(X) & 1
  33.  
  34. Examples
  35. --------
  36.  
  37. !!!! Fcn has 1 argument: Fcn(F(X)), Fcn(F(Y)) or Fcn(F(X,Y))
  38. !!!! derFcn has 2 arguments: derFcn(F(X),Fx(X)) or derFcn(F(X),1))
  39.                 ^^^^^^^^^^^              ^^^^^                ^^^
  40. 1)  derFcn = d Fcn / d X = Fcn'
  41.     ---------------------------
  42.  
  43.     Fcn = Fcn ( F(X) )
  44.     =>  d Fcn / d X = derFcn ( F(X) , Fx(X) )  ->  Fx(X) = dF/dX
  45.                                       ^^^^^^^
  46.     In fact, derFcn(F(X),Fx(X)) = Fx(X)*derFcn(F(X))
  47.               (command SYNTAX)   (calculation FORMULA)
  48.                        ^^^^^^                 ^^^^^^^
  49.     f.e.: Fcn(F(X))=Fcn(SIN(X))
  50.        => derFcn(F(X),Fx(X)) = derFcn(SIN(X),COS(X)) = COS(X)*derFcn(SIN(X))
  51.  
  52.     Fcn = Fcn ( X )
  53.     =>  d Fcn / d X = derFcn ( X , 1 )
  54.     ->  F(X) = X  =>  Fx = 1
  55.  
  56.     Fcn = Fcn ( X^2+2*X )
  57.     =>  d Fcn / d X = derFcn ( X^2+2*X , 2*X+2 )  
  58.     ->  F(X) = X^2+2*X  =>  Fx = 2*X+2
  59.  
  60.     try this:
  61.     'Fcn(F(X))' 'X' [derive] -> 'derFcn(F(X),derF(X,1))'    
  62.      -> derF(X,1)=Fx(X)
  63.  
  64. 2)  derFcn = function as is
  65.     -----------------------
  66.     
  67.     derFcn = derFcn(F(X),1) = 1 * derFcn(F(X))    
  68.                         ^^^  ^^^
  69.     ATTENTION: derFcn(F(X),0) = 0 * derFcn(F(X)) = 0
  70.                           ^^^  ^^^                ^^^
  71. 3)  [SOLV] & [INTG]
  72.     ---------------
  73.  
  74.     Both commands accepts arguments like:
  75.  
  76.  *  'Fcn(X^2+2*X)*SIN(X+pi)'
  77.  
  78.  *  'derFcn(X,1)'
  79.  
  80.  *  'derFcn(SIN(X^2),2*COS(X^2))' = 'derFcn(F(X),Fx(X))' = d Fcn / d X
  81.      -> F(X)=SIN(X^2) => Fx(X)=2*X*COS(X^2)                ^^^^^^^^^^^
  82.  
  83.  *  'derFcn(SIN(X^2),1)'          = 'derFcn(F(X),1)'     = function as is
  84.      -> = 1*derFcn(SIN(X^2))                               ^^^^^^^^^^^^^^
  85.     
  86.     try this:
  87.     'Fcn(SIN(X^2))' 'X' [derive] -> 'derFcn(SIN(X^2),2*COS(X^2))'
  88.                          ^^^^^^^^
  89.     Refer to [SOLV] and [INTG] for further information
  90.     (-> NUMERICAL LIBRARY PART 01/02 published on 16 Jun 1993)
  91.  
  92. 4)  [SYST]
  93.     ------
  94.      
  95.     Systems of equations solved by [SYST] must be DERIVABLE:
  96.  
  97.     d Fcn(F(X,Y)) / d X = derFcn(F(X,Y),Fx(X,Y))
  98.     d Fcn(F(X,Y)) / d Y = derFcn(F(X,Y),Fy(X,Y))
  99.  
  100.     The derivative of <Fcn> is defined by <derFcn>, but you can't solve 
  101.     systems including <derFcn> because its derivative <derderFcn> is
  102.     undefined!
  103.  
  104.     Refer to [SYST] for further information
  105.  
  106.  
  107. --------------------------------
  108.  
  109. DOCUMENTATION
  110. =============
  111.  
  112. FIRST Menu:
  113. [SOLV]  Solving Equation
  114. [SYST]  Solving System of Equations
  115. [INTG]  Integrating Function
  116. [DIFF]  Computing Differential Equation
  117. [ASIM]  Continual Analogical Simulation
  118.  
  119. SECOND Menu:
  120. [IPOL]  Interpolation
  121. [CFIT]  Curve Fitting
  122. [TRANS] Transforming Coordinates
  123.  
  124. THIRD Menu:
  125. [REVΣ] Reversing ΣDAT Matrix
  126. [ORDΣ] Ordering ΣDAT Matrix
  127. [DRWΣ] Plotting ΣDAT Matrix (autoscaled)
  128. [SCLΣ] Plotting ΣDAT Matrix (scale plot)
  129. [LINΣ] Connecting scattered Points by Lines
  130.  
  131.  
  132.   DOCUMENTATION
  133.   =============
  134.  
  135. Special characters (used in this documentation)
  136. -----------------------------------------------
  137.  
  138. SQRT   Square Root    131
  139. S      Integral       132   
  140. Σ      Sigma          133
  141. pi     Pi             135
  142. a      Alpha          140   [right-shift] [A]
  143. d      Delta          146   [right-shift] [D]
  144. l      Lambda         150   [right-shift] [L]
  145. r      Rho            151   [right-shift] [R]
  146. Omega  Omega          157   [right-shift] [O]
  147.  
  148. Flag State:   - 2 CF  symbolic representation  (IMPORTANT: [INTG])
  149. -----------           (-2 SF: numerical representation)    
  150.  
  151.                - 4 CF  unused system flag
  152.  
  153.               -55 CF  LASTARG disabled (probably WRONG LAST ARGUMENTS
  154.                       left on the stack in case of errors otherwise)
  155.                       (-55 SF: LASTARG enabled)
  156.  
  157.                -60 SF  ALPHA in case of alpha mode (-60 will be set by
  158.                        [Y=SF(xy)dx], [Y=SS[>dt], [CFIT] and [TRANS])
  159.                        (-60 CF: 1ALPHA mode)
  160.                        ALPHA:  Alpha lock by pressing [a] twice
  161.                        1ALPHA: Alpha lock by pressing [a] once
  162.  
  163. The following programs have been tested for these flag states. 
  164.  
  165.  
  166. [SOLV]  SOLVING EQUATION
  167. ========================
  168.  
  169. INPUT:    2: 'F(X)' or 'EQ(X)'
  170.            1: { GuessX1 | GuessX2 GuessX3 | } or GuessX
  171.  
  172. OUTPUT:   1: X: Root
  173.  
  174. DISPLAY:  running:    current X (after pressing any key)
  175.           root found: root interpretation
  176.  
  177. ERROR:    no special error message
  178.  
  179. Both <function> (internal or user-defined) and <equation> can be used as
  180. argument. You can enter either one guess or a list of maximum 3 guesses.
  181. [SOLV] uses the internal procedure of the [SOLVR] menu. No variable
  182. ('EQ' or 'X') is left in the current directory. 
  183.  
  184. N.B. - 'X' has to be the unknown variable (only 2 inputs!)
  185.        ^^^               ^^^^^^^^^^^^^^^^
  186.      - Changing variable: 'F(Z)' { Z X } |   ->   'F(X)'
  187.        |, WHERE command
  188.  
  189. The interpolation command (-> [IPOL]) is represented by the 'Fcn(X)' and
  190. 'derFcn(X)' functions. Refer to [IPOL] for further information.
  191.  
  192. EXAMPLE:  2: 'SIN(X)'
  193.           1: { 3 4 }
  194. RAD Mode 
  195. [SOLV] -> 1: X: 3.14159265359
  196.           DISPLAY: Sign Reversal 
  197.  
  198.  
  199. [SYST]  SOLVING SYSTEM OF EQUATIONS
  200. ===================================
  201.  
  202. INPUT:    4: 'F1(X,Y)' or 'EQ1(X,Y)'
  203.           3: 'F2(X,Y)' or 'EQ2(X,Y)'
  204.           2: GuessX
  205.           1: GuessY
  206.  
  207. OUTPUT:   1: X: RootX
  208.           2: Y: RootY
  209.  
  210. DISPLAY:  1) message displayed during derivation
  211.           2) current X and Y displayed during computation
  212.  
  213. ERROR:    no special error message
  214.  
  215. Both <function> (internal or user-defined) and <equation> can be used as
  216. argument. But you can't enter lists of guesses. [SYST] uses the Newton 
  217. Algorithm: both curve functions are derived by the program (message displayed
  218. during derivation). No variable is left in the current directory.
  219.  
  220. N.B. 'F1(X,Y)' (or 'EQ1(X,Y)') and 'F2(X,Y)' (or 'EQ2(X,Y)') must be DERIVABLE!
  221.      'X' and 'Y' have to be the unknown variables.                   ^^^^^^^^^
  222.      ^^^^^^^^^^^                ^^^^^^^^^^^^^^^^^
  223. The interpolation command (-> [IPOL]) is represented by the 'Fcn(X)' and
  224. 'derFcn(X)' functions. The computation time of systems including interpolation
  225.  
  226. 'Fcn(X)' and its derivative is very long because
  227. 1) the computation of 'Fcn(X)' and 'derFcn(X)' takes a long time and
  228. 2) the derivation curve 'derFcn(X)' has a wave form.
  229. Refer to [IPOL] command for further explanations.
  230.  
  231. EXAMPLE:  4: 'SQ(X)+SQ(Y)=1' circle
  232.           3: 'Y=SQRT(X)'
  233.           2: .5
  234.           1: .5
  235.  
  236. As no root interpretation procedure is included, the program doesn't interrupt
  237. the computation at a sign reversal or in case of no root! The program can be 
  238. interrupted any time by pressing [ON].
  239.  
  240. [SYST] -> 2: X: .618033988751
  241.           1: Y: .786151377759
  242.  
  243.  
  244. [INTG]  INTEGRATING FUNCTION
  245. ============================
  246.  
  247. INPUT:    2: 'F(X)'
  248.           1: { LowerLimit UpperLimit }
  249.  
  250. OUTPUT:   1: S: Integral
  251.  
  252. DISPLAY:  message displayed in case of numerical computation (computation
  253.           time can be long!)
  254.  
  255. ERROR:    no special error message
  256.  
  257. [INTG] first tries an algebraic integration, then a numerical one (message
  258. displayed). No variable is left in the current directory. In case of
  259. numerical computation, accuracy is defined by current display format (STD,
  260. FIX, ENG, SCI; STD allows the best accuracy, but increases the length of
  261. calculation time). LowerLimit and Upperlimit can be algebraic expressions
  262. including pi, e or user-defined constants (f.e. '2*pi' or 'a+e',a=1).
  263.  
  264. N.B. - Flag -2 must be cleared!
  265.        ^^^^^^^         ^^^^^^^
  266.      - 'X' has to be the unknown variable (only 2 inputs!).
  267.        ^^^               ^^^^^^^^^^^^^^^^
  268.  
  269. Interpolation: 'Fcn(X)' and 'derFcn(X)' (increases the lenght of calculation
  270. time!).
  271.  
  272. Combining [INTG] and [SOLV]:
  273. << -> A << 'LN(X)' 1 A 2 ->LIST INTG 1 - >> >> 'FCN' STO 
  274. 5 FIX
  275. 'FCN(X)' { 2 3 } [SOLV]
  276.  
  277. EXAMPLE:  2: 'SIN(X)'               2: 'SIN(ABS(X))'
  278.           1: { 0 '2*pi' }           1: { 0 '2*pi' }
  279. RAD and STD mode selected
  280.           (algebraic computation)   (numerical computation)
  281. [INTG] -> 1: S: 0                    1: S: -3.67374857952E-12
  282.  
  283. EXAMPLE:  2: 'LN(X)'
  284.           1: { 0 e }
  285.            (algebraic computation)
  286. [INTG] -> 1: S: 0
  287. This calculation would be impossible by using numerical computation!
  288.  
  289.  
  290. [DIFF]  COMPUTING DIFFERENTIAL EQUATION
  291. =======================================
  292.  
  293. [DIFF] activates a special menu:
  294.  
  295.  
  296.          [Y=SF(xy)dx]   Computing Y'=f(X,Y,l), Y'=dY/dX
  297.          (label 1 & 2 & 3)
  298.  
  299.          [Y=SS[>dxdx]     Computing Y"=f(X,Y,d), Y"=d^2Y/dX^2
  300.          (label 4 & 5 & 6)
  301.  
  302.                | [Y=SF(xy)dx]          | [Y=SF(xy)dx]          | [Y=SS[>dt]
  303.                | (first algorithm)     | (second algorithm)    |
  304. -------------------------------------------------------------------------------
  305.  
  306.  
  307. computes      |  Y'                    | Y'                    | Y"
  308.               |                        |                       |^^^^
  309. variables     |  X, Y                  | X, Y, l               | X, Y, d
  310.               |                        |      ^^^              |
  311. integr.var.   | dx                     | dx                    | dx
  312.               |                        |                       |
  313. algorithm     |  Runge-Kutta           | (Heun)                |  Analogical  
  314.               |                        |                       |
  315. order         | 4th                    | 2nd                   | 1st
  316.               |^^^^^                   |                       |
  317. accuracy:     | flat: very good        | flat: good            | flat: suffic.
  318.               |       ^^^^^^^^^        |                       |
  319.               |  +/-90: bad            | +/-90: good           | +/-90: very bad
  320.               |                        |        ^^^^           |
  321. init.val.=    | X0, Y0                 | X0, Y0                | Y0, d0
  322.               |                        |                       |
  323. comp.step dH= | +/-dX                  | +/-SQRT(dX^2+dY^2)    | +/-dX  
  324.               |                        |                       |
  325. stor.step dS= | +dS                    | +dS                   | +dS
  326.               |                        |                       |
  327. dX=           | con=dH                 | var=dH*COS(a)         | con=dH
  328.               |                        | ^^^^^^^^^^^^^         |
  329. sim.interval= | [ Xb Xe ]              | No                    | [ X0 Xe ]
  330.               |                        |                       |
  331. RAD mode      | no                     | yes                   | no
  332.               |                        |                       |
  333. ΣDAT          | appends                | appends               | overwrites
  334.               | ^^^^^^^                | ^^^^^^^               | 
  335.  
  336. [Y=SF(xy)dx]   Computing Y'=f(X,Y,l), Y'=dY/dX
  337. ==============================================
  338.  
  339. First EXAMPLE
  340. vvvvvvvvvvvvv
  341.  
  342. [Y=SF(xy)dx] -> |Enter Differential EQ
  343.                  | Y'=f(X,Y.l):
  344.  
  345. Algebraic enter mode is activated. 1ALPHA in case of alpha mode. l (lambda; 
  346. [right-shift] [L]) represents the length of the curve arc. EDIT menu is
  347. activated (-> [->STK] command).   ^^^^^^^^^^^^^^^^^^^^^^^
  348.  
  349.           |'TAN(SQ(l)/2) <ENTER>           l = [right-shift] [L]
  350.  
  351.            |Enter Initial Values
  352.            | X0 and Y0:
  353.  
  354. l0 (lambda0)=0 by default! EDIT menu is now desactivated ([left-shift] [+/-]
  355. ^^^^^^^^^^^^^^              to reactivate).
  356.          
  357.            | 0 <SPACE> 0 <ENTER>
  358.  
  359.            |Enter Computation step
  360.            | +/-dH:
  361.  
  362.            | .02 <ENTER>
  363.  
  364.            |Enter Storage Step
  365.            | +dS:
  366.  
  367. |----:---------------------/  /--------------------------> curve arc [l]
  368.     l0 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^      ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ computation step dH=0.2
  369.      ^     ^     ^     ^          ^     ^     ^     ^ storage step dS=3*dH=0.6
  370.      0     1     2                     n-2   n-1    n n=number of steps
  371.  
  372. Choosing a computation step |dH| < than dS allows a greater accuracy of stored
  373. points. Data points are stored into 'ΣDAT'. If 'ΣDAT' already exists, points
  374. are appended!
  375.     ^^^^^^^^
  376.            | .06 <ENTER>
  377.  
  378. Every third ( ABS(IP(dS/dH))=ABS(IP(.06/.02))=3 ) point is stored into
  379. 'ΣDAT'.
  380.  
  381.            |>ae]-90 90[ >ae[0 360]    |
  382.            |dx=h        dx=h*cosa     | Algorithm formulae
  383.            |dy=h*tana   dy=h*sina     |
  384.            |l=undefined l=Eh          > l=current length of curve arc *
  385.            |>4th Order  >2nd Order    > Order of computation **
  386.            |[ ] /\ [ ] [ ] /\ [ ]     Press [/\] to choose algorithm
  387.  
  388. *   First algorithm is unable to compute the current length of the curve arc.
  389.     The computation time would have been too long!
  390.  
  391. **  The first algorithm comptes at a better accuracy in case of FLAT curves,
  392.     but fails in case of GREAT gradients (around +/-90 degrees) because dX=dH
  393.     is constant (choose the second algorithm: dX=dH*COS(a)!). A 4th order
  394.     computation in case of a variable dX would have been too difficult to
  395.     program and the calculation too long, too!
  396.  
  397. IMPORTANT:
  398. During computation of the second algorithm, RAD mode is automatically selected
  399. for programming reasons.  ^^^^^^^^^^^^^^^^  ^^^^^^^^
  400.  
  401.            |              </\>            second algorithm (able to compute l)
  402.  
  403.            |Enter Number of Steps
  404.            | No:
  405.            |
  406.            | 80 <ENTER>
  407.  
  408. 80 points ( [ Xn Yn ] ) are stored into 'ΣDAT' (240 points are computed).
  409. The result curve is then drawn as a scale curve. If an error occures 
  410. during computation, the program interrupts without drawing a curve. 
  411.  
  412. Second EXAMPLE
  413. vvvvvvvvvvvvvv
  414.  
  415. 'ΣDAT' PURGE         Data points would be appended to the former computation
  416.  
  417. [Y=SF(xy)dx] -> |'-SIN(X) <ENTER>        Y'=-SIN(X)      Differential equation
  418.                  | 0 <SPACE> 1 <ENTER>    X0=0 and Y0=1   Initial values
  419.                  | .02 <ENTER>            dH=.02          Computation step
  420.                  | .1 <ENTER>             dS=.1           Storage step
  421.  
  422. |------------------------------------------------------> [X]
  423.    ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^  computation step dH=.02
  424.      ^         ^         ^         ^         ^        storage step dS=5*dH=1
  425.  
  426.                  |   </\>                 First algorithm (dH=dX)
  427.  
  428. IMPORTANT:
  429. During computation of the first algorithm, RAD mode is *NOT* selected 
  430. automatically as during the second one:    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  431. [left-shift] [1] to select RAD.
  432.  
  433.                  |Enter Storage Interval
  434.                  | [Xb Xe]:
  435.  
  436.                  | 0 <SPACE> 6.3 <ENTER>
  437.  
  438. X0 <= Xb < Xe
  439. vvvvvvvvvvvvv
  440.  
  441. |-----:---------------:----------:------------> [X]
  442.      X0              Xb         Xe
  443.       |--------------------------> computation interval
  444.                        |----------> storage interval
  445.  
  446. X0 >= Xb > Xe
  447. vvvvvvvvvvvvv
  448.  
  449. [-X] <------:--------------:-----------:-------|
  450.            Xe             Xb          X0
  451.             <--------------------------| computation interval
  452.             <--------------|             storage interval
  453.  
  454. These data points are used by the second example of [IPOL].
  455.                  
  456.  
  457. [Y=SS[>dt]     Computes Y"=f(X,Y,d), Y"=d^2Y/dX^2
  458. =================================================
  459.  
  460. The [>-block represents the analogical algorithm. [Y=SS[>] uses the [ASIM]
  461. programs to compute the differential equation of the 2nd degree. [ASIM] does 
  462. continual simulation => time T = independent variable! But for the computation
  463. of differential equations with [Y=SS[>dt], T = X !
  464.  
  465. [Y=SS[>dt] defines 3 blocks and combines them to an analogical system:
  466.  
  467. Y"                   Y'                    Y
  468.  ---[INTEGRATOR 50>-------[INTEGRATOR 50>---
  469. |                     |                     |
  470. |                     |                     |  X
  471.  --<DIFFERENTIAL 101]-----------------------------<TIME)
  472.  
  473. Refer to [ASIM] for more information about analogical systems.
  474.  
  475. N.B. d (delta: [right-shift] [D]) = Y' (gradient). Y'-synatx isn't accepted by
  476.      the enter procedure.
  477.  
  478. EXAMPLE
  479. vvvvvvv
  480.  
  481. [Y=SS[>dt] -> |Enter Differential EQ
  482.                | Y"=f(X,Y,d):
  483.  
  484.                | 2 <ENTER>
  485.  
  486. Y"=2  =>  Y'=2*X  =>  Y=X^2
  487.  
  488.                |Enter Initial Values
  489.                | Y0 and d0:
  490.  
  491. d0=Y'0
  492.  
  493.                | 0 <SPACE> 0 <ENTER>
  494.  
  495.                |   Compiling System                  [ASIM] compiler
  496.                 
  497.                |Simulation Interval
  498.                | [Tb Te]:
  499.  
  500. Simulation interval [Tb Te] = computation interval [Xb Xe] (N.B. [ASIM]
  501. does continual simulation -> time T = independent variable!)! Tb=Xb=X0!
  502. Tb=Xb can be > than Te=Xe -> negative computation step dT=dX. ^^^^^^^^
  503. ^^^^^               ^^^^^                              ^^^^^
  504. Xb=X0 < Xe
  505. vvvvvvvvvv
  506.  
  507. |--------:-----------------------:--------------> [X]
  508.         X0                      Xe
  509.          |-----------------------> computation interval = storage interval
  510.  
  511. Xb=X0 > Xe
  512. vvvvvvvvvv
  513.  
  514. [-X] <--------:----------------------:-------|
  515.              Xe                     X0
  516.               <----------------------| computation interval = storage interval
  517.  
  518.                | 0 <SPACE> 1 <ENTER>
  519.                 
  520.                |Enter Computation Step
  521.                | +dT:
  522.  
  523. Again: dT=dX! (remember that!)
  524.  
  525.                | .01 <ENTER>
  526.  
  527.                |Enter Storage Step
  528.                | +dS:
  529.  
  530. |---------------------------------------------------> [X]
  531.   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^  computation step dX=.01
  532.   ^                   ^                   ^          storage step dS=10*dH=.1
  533.  
  534.                | .1 <ENTER>
  535.  
  536. 100 points are computed, 10 are stored in 'ΣDAT'. Former 'ΣDAT' points
  537. are cleared (data points are NOT APPENDED! -> [ASIM]).
  538.  
  539. Result ('ΣDAT' variable):
  540.  
  541.     X   Ycalc       Ycorr
  542. [[ 0.0  0.000 ]     0.000
  543.  [ 0.1  0.011 ]     0.010
  544.  [ 0.2  0.042 ]     0.040
  545.  [ 0.3  0.093 ]     0.090
  546.  [ 0.4  0.164 ]     0.160
  547.  [ 0.5  0.255 ]     0.250
  548.  [ 0.6  0.366 ]     0.360
  549.  [ 0.7  0.497 ]     0.490
  550.  [ 0.8  0.648 ]     0.640
  551.  [ 0.9  0.819 ]     0.810
  552.  [ 1.0  1.010 ]     1.000
  553.  
  554.  
  555. [ASIM]  CONTINUAL ANALOGICAL SIMULATION
  556. =======================================
  557.  
  558. [ASIM] activates special menu:
  559.  
  560.          [()-[> ] DEFINE, RECALL or CLEAR Blocks
  561.          [()-()-] CHANGE Parameter of Blocks
  562.          [<< >> ] COMPILE analogical Structure
  563.          [ E [> ] STORE Blocks during Computation
  564.          [ o-[] ] SIMULATE analogical Structure
  565.          [|__/\_] DRAW Block Curve
  566.  
  567. These commands allow to define blocks and to combine them to an analogical
  568. structure.
  569.  
  570. DEFINITION (Schaum's outline series: Theory of feedback and control systems):
  571. A system is an arrangement of physical components connected or related in such
  572.  
  573. a manner as to form and/or act as an entire unit. Control systems are 
  574. classified into two general categories: OPEN-LOOP and CLOSED-LOOP systems. 
  575. The distinction is determined by the CONTROL ACTION, which is that quantity 
  576. responsible for activating the system to produce the output:
  577.  - an OPEN-LOOP control system is one in which the control action is 
  578.    independent of the output.
  579.  - an CLOSED-LOOP control system is one in which the control action is somehow
  580.    dependent on the output.
  581. Both OPEN-LOOP and CLOSED-LOOP control systems can be combined.
  582.  
  583. ATTENTION:
  584. An CLOSED-LOOP control system MUST ALWAYS contain at least ONE INTEGRATOR
  585. (block type 50,51 or 52)! Control systems simulated by the [ASIM]-Program
  586. MUST ALWAYS include at least ONE INTEGRATOR, even in case of an OPEN-LOOP!
  587. Otherwise the [<< >> ]-compiler errors ("Integrator missing" or
  588. "Short Circuit in **"; refer to [<< >> ]).
  589.  
  590. EXAMPLES
  591. vvvvvvvv
  592.  
  593.      INPUT          OUTPUT-< ]-INPUT    -[I>- INTEGRATOR       [C>- CONSTANT
  594.        |                    | 
  595. INPUT-[ >-OUTPUT          INPUT          (t)- CURRENT TIME    -[Q>  QUIT
  596.  
  597.  
  598. (t)---[ >---[ >---[I>---[ >---[ >    (t)---[ >---[ >---[I>---[ >
  599.           |              |                     |           |
  600.            -------[ >----                       ----< ]----
  601.  
  602.         -------< ]----       -[Q>    (t)---[ >---[ >---[ >---[I>
  603.        |              |     |                  |        |
  604. (t)---[ >---[ >---[I>---[ >-                    --[ >---
  605.              |        |     |
  606.               --< ]---      |        [C>---[I>---[ >---[ >---[ >          
  607.                  |          |                     |     |
  608.                   ----------               [C>----------
  609.  
  610. N.B. - In fact, simulating an analogical structure means to compute
  611.        a (system of) differential equation(s). 
  612.        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  613.      - [()-[> ], [<< >> ] and [ E [> ] create several variables in the current
  614.  
  615.        menu (named 'Omega***'). Before defining an analogical system, create a
  616.  
  617.        new directory! (Character 'Omega' = [right-shift] [O])         ^^^^^^^^
  618.        ^^^^^^^^^^^^^
  619.  
  620. [()-[> ] DEFINE, RECALL or CLEAR Blocks
  621. =======================================
  622.  
  623.          DEFINE BLOCK        CLEAR BLOCK        RECALL BLOCK
  624.          vvvvvvvvvvvv        vvvvvvvvvvv        vvvvvvvvvvvv
  625.  
  626. INPUT:   4: Block Number
  627.           3: Block Type
  628.           2: { Entries }      2: Block Number
  629.           1: { Parameters }   1: 0               1: Block Number
  630.  
  631. OUTPUT:  none                none               4: Block Number
  632.                                                  3: Block Type
  633.                                                  2: { Entries }
  634.                                                  1: { Parameters }
  635.  
  636. DEFINE BLOCK
  637. ------------
  638.   Every block has several inputs (from other blocks or parameters), but only
  639. ONE output. A block is defined by its block number (its "name"), its block
  640. type (defining its action), its entries (from other blocks) and its
  641. parameters. There are special block types without any entry (56 and 60).
  642. Block number 100 represents the current time during computation. [()-[> ]
  643. always owerwrites former block definitions.
  644.  
  645.   50 different block types are predefined (refer to block list at the end of
  646. this documentation), some types are undefined (f.e. 23). The creation of
  647. user-defined block types is possible: 
  648. A user-defined block type consists of a program stored under global name
  649. 'OmegaNNN' (NNN > 100). This program must compute the exact number of block
  650. entries (E) and parameters (P) you indicated in the { Entires } and 
  651. { Parameters } lists during definition. The count of E's and P's is not tested
  652. as for the predefined block types! The program must only have ONE output E0!
  653.  
  654. RECALL BLOCK
  655. ------------
  656.   To recall a block definition, just enter its number. Block number, block
  657. type, entry list and parameter list are put on stack.
  658.  
  659. CLEAR BLOCK
  660. -----------
  661.   To clear an already defined block, enter its number and a zero. In fact,
  662.   blocks are not cleared, but replaced by the block type 60 (Null). This to
  663.   avoid a block entry from an undefined (cleared) block (refer to [<< >> ]
  664.   errors).
  665.  
  666. Note: - user-defined block type program form:
  667.          << -> E1 E2 P1 P2 P2 << ... >> >>
  668.          Block entries (E) BEFORE parameters (P)!
  669.  
  670.         EXAMPLE:
  671.  
  672.         block type: 101
  673.         action:     E0=E1^P1+E2^P2
  674.         E:          2
  675.         P:          2
  676.          
  677.         'Omega101': << -> E1 E2 P1 P2 << E1 P1 ^ E2 P2 ^ + >> >>
  678.                     << -> E1 E2 P1 P2 'E1^P1+E2^P2' >> >>
  679.                     << ROT SWAP ^ 3 ROLLD ^ + >> is of course possible!
  680.  
  681.  !!!! - A negative block entry means that the sign of the input from this
  682.  !!!!   block is automatically changed (refer to the example).
  683.  
  684.       - { } means NO entry or parameter (E=0 or/and P=0 in block list).
  685.  
  686.       - Character Omega = [right-shift] [O]
  687.  
  688.  !!!! - AFTER every change, the system has to be compiled BEFORE it can be
  689.  !!!!   computed as new system!
  690.  
  691. VARIABLES:
  692. OmegaBLC   block entries
  693. OmegaPAR   block parameters
  694. OmegaTYP   block types
  695. OmegaINT   Integrators
  696. OmegaDER   d/dt blocks
  697. OmegaINIT  initial values of integrators
  698.  
  699. ERRORS: 
  700. "Wrong Entry Count"     Refer to block list under column E
  701. "Wrong Parameter Count" Refer to block list under column P
  702. "Type ** undefined"     Refer to block list under column NBR & ACTION
  703. "Block ** undefined"    Trying to recall an undefined block
  704.        
  705.  
  706. [()-()-] CHANGE Parameter of Blocks
  707. ===================================
  708.  
  709. INPUT:   2: Block Number
  710.           1: { Parameters } or Parameter (Initial Value of Integrator)
  711.  
  712. OUTPUT:  none
  713.  
  714. This command allows to change the parameters of an ALREADY defined block.
  715. To simply change the initial value of an integrator (block number 50,51,52),
  716. just enter its block number and the initial value (not included in a list).
  717.  
  718. N.B. AFTER every change, the system has to be compiled BEFORE it can be
  719.      simulated!
  720.  
  721. ERRORS: 
  722. "Wrong Parameter Count" Refer to block list under column P
  723. "Block ** undefined"    Trying to change the parameters of an undefined block
  724.  
  725.  
  726. [<< >> ] COMPILE analogical Structure
  727. =====================================
  728.  
  729. INPUT:   none
  730.  
  731. OUTPUT:  none
  732.  
  733. Before a system can be simulated, it has to be compiled. The compiled
  734. system (program) is stored into global name 'OmegaPRG'.
  735.  
  736. IMPORTANT: AFTER every change (block definition or just a parameter), the
  737.            system has to be compiled BEFORE it can be computed!
  738.  
  739. VARIABLES:
  740. OmegaORD   order of block output computation
  741. OmegaPRG   compiled system
  742.  
  743. ERRORS: 
  744. "Integrator missing"  No integrator at all was defined
  745. "Short Circuit in **" Closed-loop (containing block **) without integrator
  746. "Block ** undefined"  Block entry from an undefined block
  747.  
  748.  
  749. [ E [> ] STORE Blocks during Computation
  750. ========================================
  751.  
  752. INPUT:   1: { Block Numbers } or { 0 } or BlockNumber
  753.  
  754. OUTPUT:  none
  755.  
  756. Not every block output is important. You can pick out all the outputs
  757. you are interested in. { 0 } means that ALL blocks are stored during
  758. computation. Remember that block number 100 represents the current time.
  759. [ E [> ] creates a program stored into global name 'OmegaSTO'. [ E [> ]
  760. changes don't have to be compiled, but the storage list has to be defined
  761. before the system can be simulated!
  762.  
  763. To create a 'ΣDAT' matrix compatible with [IPOL], [CFIT] and [TRANS] etc
  764. (size = { n 2 }), enter { 100 BlockNumber } as storage list (X: Time, Y: Bock)
  765. or just BlockNumber (means { 100 BlockNumber }).
  766.  
  767. VARIABLES:
  768. OmegaSTP   list of blocks to be stored during simulation
  769. OmegaSTO   program to store blocks during simulation
  770.            
  771. { 100 5 3 }   [ E [> ] -> OmegaSTP = { 100 5 3 }
  772.                            OmegaSTO = << OmegaTIM OmegaVAL 5 GET OmegaVAL 3
  773.                                          GET 3 ->ARRY Σ+ OmegaTIM 7 DISP
  774.                                       >>
  775.                            You can of course change that program or even
  776.                            replace it by an user-defined program (f.e. which 
  777.                            prints the current block values)
  778.                            EXAMPLE:
  779.                            OmegaSTO = << "                        " 1 OmegaTIM
  780.                                          0 FIX ->STR REPL 5 OmegaVAL 5 GET
  781.                                          3 FIX ->STR REPL 10 OmegaVAL 3 GET
  782.                                          1 FIX ->STR REPL PR1 DROP OmegaTIM
  783.                                          7 DISP               ^^^^
  784.                                       >> 
  785.                            prints without storing results!
  786.                       N.B. OmegaSTO must not have an output!
  787.                                     ^^^^^^^^^^^^^^^^^^^^^^^
  788. ERRORS: no special error message
  789.  
  790.  
  791. [ o-[] ] SIMULATE analogical Structure
  792. ======================================
  793.  
  794. INPUT:   none
  795.  
  796. OUTPUT:  none
  797.  
  798. [ o-[] ] -> |Simulation Interval:
  799.              | [Tb Te]:
  800.  
  801. Enter the time interval (f.e. from 0 [?] to 100 [?], unit [?] depends always
  802. on the current system):
  803.  
  804. Tb < Te
  805. vvvvvvv
  806.  
  807. |------:--------------------:-----------> [T]
  808.       Tb                   Te
  809.        |--------------------> computation interval = storage interval
  810.  
  811. Tb > Te
  812. vvvvvvv
  813.  
  814. [-T] <-------:--------------------:----------|
  815.             Te                   Tb
  816.              <--------------------| computation interval = storage interval
  817.  
  818.              |0 <SPACE> 100 <ENTER>
  819.  
  820.              |Enter Computation Step:
  821.              | +dT:
  822.  
  823. Enter the time step of computation (f.e. 0.1 [?]):
  824.  
  825.              |.1 <ENTER>
  826.  
  827.              |Enter Storage Step:
  828.              | +dS:
  829.                  
  830. Enter the time step to store the blocks indicated by the command [ E [> ]:
  831.  
  832. |--------------------------------------------------------> [T]
  833.   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ computation step dT=.1 
  834.     ^                   ^                   ^     storage step dS=10*dT=1
  835.              |1 <ENTER>
  836.  
  837.              | SIMULATING
  838.  
  839. Simulation begins ... Blocks outputs are stored into 'ΣDAT' matrix.
  840.  
  841. During simulation, the program uses special variables (which can be used by
  842. user-defined block types):
  843.  
  844. - OmegaTIM:  current simulation time
  845.  
  846. - OmegaCNT:  step count
  847.               1st step=initial time Tb
  848.               2nd step=Tb+dT, dT=time step
  849.               number of steps = (Te-Tb)/dT
  850.  
  851. - OmegaDT:   time step dT
  852.  
  853. ERRORS: 
  854. "Structure not compiled" Trying to simulate a non-compiled system. Refer to
  855.                           [<< >> ] command.
  856. "Storage List missing"   Trying to simulate without indicating the blocks
  857.                           to be stored during computation. Refer to [ E [> ]
  858.                           command.
  859.  
  860.  
  861. [|__/\_] DRAW Block Curve
  862. =========================
  863.  
  864. INPUT:   1: Block Number or 0
  865.  
  866. OUTPUT:  none
  867.  
  868. Just enter the number of the block of which you want to draw the result curve
  869. (Plot Type: BARPLOT). If you entered { 100 BlockNumber } or BlockNumber as
  870. storage "list" (means 2 "blocks" only!) (refer to [ E [> ], 0 as BlockNumber
  871. produces a SCATTER drawing.
  872.  
  873. ERRORS: 
  874. "Block ** undefined"  Trying to draw the result curve of an undefined block
  875. "Block ** not stored" Trying to draw the result curve of a block which was not
  876.                        included in the storage list (refer to [ E [> ])
  877.  
  878.  
  879. BLOCK TYPE DEFINITIONS at the end of documentation
  880. ----------------------
  881.  
  882. FIRST EXAMPLE
  883. -------------
  884. __
  885.   \___  affluent R [m^3/h]
  886.       \___________                weir W [m^3/h]
  887.                    \ area A [m^2]  ___     
  888.                     \~~~~~~~~~~~~~| | \    ^
  889.                      \   depth H  | |      |
  890.                       \    [m]    | |      | initial depth of water
  891. H0=20m
  892.                        \          | |      | 
  893.                         \_________| |      v
  894.                                   | |dam: heigth=21m, width=4m
  895.                                                                   
  896.                                                                 Area(H)
  897.                                                          [m2]  --------
  898.                                                         ------<Omega102|<---
  899.                                                        | (A)   --------     |
  900.                                                        |         *6*        |
  901.                                                        |                    |
  902.           Affluent(t)                  (1/3600)       |                   
  903.  |
  904. Time  [h]  --------  [m3/h]               |           v        INTEGRATOR  |
  905. (100)---->|Omega101>--------> --  [m3/h]  --  [m3/s]  -- [m/s]   ----  [m] |
  906.            --------  (R) (+) |15>------->|20>------->|18>--->(1)| 50 >-----|
  907.              *1*         ---> --          --          -- (dH)    ----  (H) |
  908.                         |(-)  *2*         *3*         *4*        |  *5*    |
  909.                         |                                       (20)=(H0)   |
  910.    *BlockNumber*        |                                                   |
  911.      ---------          |                                     Wire(H) *7*   |
  912.     |BlockType>         |                             [m3/h]  --------     |
  913.      ---------           ------------------------------------<Omega103|<---
  914.                                                        (W)     --------
  915. Blocks 2,3,4,5,7 are forming a CLOSED-LOOP.                     |    |
  916. Blocks 4,5,6 are also forming a CLOSED-LOOP.                   (21) (4)
  917. Both CLOSED-LOOPs contain block 5 as INTEGRATOR.       Dam height   Dam width
  918. Block 2: the input -from block 1- sign is (+),
  919. input -from block 7- sign is (-) ( -> outlet ).
  920.  
  921. Block Definition:
  922.  
  923. NBR TYPE  ENTRIES  PARAMETERS
  924.  
  925.   1  101  { 100 }   { }        [()-[> ]
  926.   2   15  { 1 -7 }  { }        [()-[> ]    Note input signs!
  927.   3   20  { 2 }     { 3.6 }    [()-[> ]
  928.   4   18  { 3 6 }   { }        [()-[> ]
  929.   5   50  { 4 }     { 20 1 }   [()-[> ]
  930.   6  102  { 5 }     { }        [()-[> ]
  931.   7  103  { 5 }     { 21 4 }   [()-[> ]
  932.  
  933. User-defined block types:
  934.  
  935. Block type 101: (Affluent)
  936. << -> E1 << ... >> >>
  937. 'Omega101' STO
  938.  
  939. Block type 102: (Area: function of depth H)
  940. << -> E1 << ... >> >>
  941. 'Omega102' STO
  942.  
  943. Block type 103: (Wire: function of depth H, dam height and dam width)
  944. << -> E1 P1 P2 << ... >> >>
  945. 'Omega103' STO
  946.  
  947. Compiling:                     [<< >> ]
  948. Storage List:       { 1 5 7 }  [ E [> ]
  949.  
  950. Simulating:                    [ o-[] ] -> |0 <SPACE> 24 <ENTER>  Time
  951. Interval
  952.                                             |.1 <ENTER>            Comp. Step
  953.                                             |.4 <ENTER>            Storage Step
  954.  
  955. Draw Curve:         5          [|__/\_]  Depth Curve
  956.  
  957. SECOND EXAMPLE
  958. --------------
  959.  
  960. Differential Equation Y'''=f(Y,Y',Y'',t), Y'''=d^3Y/dt^3
  961. Y''(0)=A3
  962. Y'(0)=A2
  963. Y(0)=A1
  964.  
  965. Analogical System:
  966.  
  967.          (A3,1)                (A2,1)                (A1,1)
  968.            |        Y''          |        Y'           |        Y
  969.  ---[INTEGRATOR 50>-------[INTEGRATOR 50>-------[INTEGRATOR 50>---
  970. |         *1*         |         *2*         |         *3*         |
  971. |                     |                     |                     |  T
  972.  --<DIFFERENTIAL 101]--------------------------------------------------<TIME)
  973.          
  974.    
  975.           *4*
  976.  
  977. NBR    TYPE    ENTRIES        PARAMETERS 
  978.  1      50     { 4 }          { A3 1 }      [()-[>]   Integrator 1: E0=Y''
  979.  2      50     { 1 }          { A2 1 }      [()-[>]   Integrator 2: E0=Y'
  980.  3      50     { 2 }          { A1 1 }      [()-[>]   Integrator 3: E0=Y
  981.  4     101     { 1 2 3 100 }  { ? }         [()-[>]   Differential: E0=Y'''
  982.  
  983.  !!!! You should ENTER (not: number; not important) the INTEGRATORS in THAT
  984.  !!!! particular order (E0=Y'' -> E0=Y' -> E0=Y). If you "connect" several
  985.  !!!! integrators in series, you should always ENTER the INTEGRATORS in "flow
  986.  !!!! direction" order. This is due to programming and algorithm reasons.
  987.  
  988. Omega101: << -> Y2 Y1 Y0 T | Pn | << ... >> >>
  989.  
  990. Compile and simulate (from T0=0 to T=TE) the system ...
  991.  
  992. NOTE: this method corresponds to the [Y=SS[>dt] algorithm (dT=const; 1st
  993.       order computation). This analogical system fails in case of great
  994.       gradients (around +/-90 degrees).
  995.       Refer to [Y=SS[>dt] for more information about differential equations.
  996.  
  997. ACCURACY
  998. --------
  999.  
  1000. Computing differential equations either with the Runge-Kutta (4th order)
  1001. or Heun (2nd order) algorithm is very accurate, but integrating these
  1002. equations
  1003. step by step with an analogical system is not! Calculation blocks as [COSINE>,
  1004. [LOGARITHM>, [MULTIPLICATION> or [LIMIT> (blocks 1-22, 25-33 and 36-47) are as
  1005. accurate as the HP48 itself, but accuracy of [INTEGRATION>-blocks depends on
  1006. their algorithm formula => on dt:
  1007.  
  1008.      (I0)
  1009.       |
  1010. E----[I>----O, E=F(t) (open-loop) or E=F(t,O) (closed-loop)
  1011.  
  1012. - at t=0, I=I0
  1013.                                           m=n
  1014. - In+1 = In + E * dt (first order) = I0 + Σ dI, dI=E*dt
  1015.                                           m=0
  1016.               m=n     n
  1017. - dt ~ 0  =>  Σ dI ~ S dI, Σ Sigma, S Integral
  1018.               M=0     0
  1019.   => choosing dt<<1 -> greater accuracy
  1020.   but: increases length of time to calculate!
  1021.  
  1022.  
  1023. [IPOL] [CFIT] [TRANS] [REVΣ] [ORDΣ] [DRWΣ] [SCLΣ] [LINΣ]
  1024. =============================================================
  1025.  
  1026.    ******************************
  1027.    * I  M  P  O  R  T  A  N  T  *
  1028.    ******************************
  1029.  
  1030.   All these commands need 'ΣDAT' matrix under special form:
  1031.  
  1032.     - 'ΣDAT' size = { n 2 }
  1033.     - First column of 'ΣDAT' = Xn
  1034.     - Second column of 'ΣDAT' = Yn
  1035.     - [IPOL] ONLY: X-column in GROWING order, Xn > Xn-1!
  1036.       ^^^^^^^^^^^              ^^^^^^^
  1037.  
  1038.   [DIFF] commands create 'ΣDAT' in growing order if:
  1039.   -dX=dH > 0 (first algorithm of [Y=SF(xy)dx])
  1040.   -dX=dH*COS(a) > 0 (second algorithm of [Y=SF(xy)dx])
  1041.   -dT=dX > 0 ([Y=SS[>dt])
  1042.  
  1043.   Otherwise: [REVΣ] to reverse 'ΣDAT'
  1044.              [ORDΣ] to order 'ΣDAT'
  1045.  
  1046.  
  1047. [IPOL]  INTERPOLATION
  1048. =====================
  1049.  
  1050. INPUT:    1: RealX
  1051.  
  1052. OUTPUT:   2: d: Derivative
  1053.            1: Y: RealY
  1054.  
  1055. DISPLAY:  no special message displayed
  1056.  
  1057. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1058.           "Wrong ΣDAT Size"  ΣDAT size is different from { n 2 }
  1059.  
  1060. [IPOL] lets you interpolate data points stored in GROWING order in
  1061. 'ΣDAT':
  1062.  
  1063.         [Y]
  1064.          ^                   (m)
  1065.   (1)    |                    x
  1066.    x   (2)              (m-1)
  1067.         x|                x
  1068.         :|   x         x  |
  1069.         :|          x     :
  1070.         :|                :
  1071. --------:-----/  /--------:-------> [X]
  1072.         :|                :
  1073.         :                 :
  1074. -------><-----------------><--------
  1075.   2nd           5th            2nd       polynomial degree (of interpolation)
  1076.   1st           4th            1st       derived polynomial degree
  1077.  
  1078. Interpolation between (Xn,Yn) and (Xn+1,Yn+1):
  1079. (1) F(Xn)=Yn
  1080. (2) F(Xn+1)=Yn+1
  1081. (3) F'(Xn)=(Yn+1 - Yn-1)/(Xn+1 - Xn-1)
  1082. (4) F'(Xn+1)=(Yn+2 - Yn)/(Xn+2 - Xn)
  1083. (5) F"(Xn)=0
  1084. (6) F"(Xn+1)=0
  1085. 6 conditions => IPOL(X), polynomial of 5th degree
  1086. => derivation DER(X), polynomial of 4th degree
  1087. and: (5) & (6) => DER'(Xn)=DER'(Xn+1)=0 
  1088.                => wave form
  1089. DER(X) curve:    __._---_.__
  1090.            __.__/  |     |  \__.__--
  1091.      __.__/  |     |     |     |
  1092.   __/  |     |     |     |     |
  1093.        |     |     |     |     |
  1094.   -----:-----:-----:-----:-----:-----> [X]
  1095.  
  1096. First EXAMPLE
  1097. vvvvvvvvvvvvv
  1098.  
  1099. Let's create an apropriate 'ΣDAT' matrix:
  1100.  
  1101. 'ΣDAT' PURGE  ([Y=SF(xy)dx] appends data points to former computation)
  1102.  
  1103. [DIFF] 
  1104. [Y=SF(xy)dx] -> | l <ENTER>              Y'=l (lambda)  
  1105.                  | 0 <SPACE> 1 <RETURN>   X0=0, Y0=1
  1106.                  | .1 <ENTER>             dH=.1
  1107.                  | .1 <ENTER>             dS=.1=dH (every point is stored)
  1108.                  |             </\>       second algorithm (able to compute l)
  1109.          | 10 <ENTER>             10 points
  1110.  
  1111. Differential equation Y'=l [Gradient = Function(CurveArc)]
  1112.                    => Y=COSH(X) !!
  1113. That's why I proposed the initial values X0=0 and Y0=1!
  1114.  
  1115. [IPOL] interpolates the data points from the 'ΣDAT' matrix:
  1116.  
  1117. .5 [IPOL]  ->  d(.5)/dX= 0.510410896178     | SINH(0.5)= 0.521095305494
  1118.                       Y= 1.127241126120     | COSH(0.5)= 1.127625965210
  1119.  
  1120. These data points are also used for the example of [CFIT].
  1121.  
  1122. Second EXAMPLE
  1123. vvvvvvvvvvvvvv
  1124.  
  1125. Use the data points from the second example of [Y=SF(xy)dx].
  1126.  
  1127. As Y'=-SIN(X), Y=COS(X). Let's try to find the root X=pi/2 by using [IPOL]
  1128. and [SOLV]. As [IPOL] has TWO tagged outputs, we would have to create a 
  1129. program (function form) which has ONLY the (real) output Y:
  1130. <<  ->  X  <<  X  IPOL  SWAP  DROP  0  +  >>  >>  'Fcn'  STO
  1131. But during execution of [SOLV] ([SYST] and [INTG]), the interpolation
  1132. functions
  1133. 'Fcn(X)' and 'derFcn(X)' are predefined! Refer to [SOLV] and [SYST].
  1134.  
  1135.           2: 'Fcn(X)'
  1136.           1: { 1 2 }
  1137.  
  1138. [SOLV] -> 1: X: 1.57077308547      
  1139. and:      pi/2= 1.57079632680
  1140.  
  1141. Note: -Program with Y output (as real):
  1142.  
  1143.        <<  ->  X  <<    | function form  
  1144.        X  IPOL          | calculates 2: d: and 1: Y:
  1145.        SWAP  DROP       | drops d:
  1146.        0  +             | Y: (tagged) -> Y (real)
  1147.        >>  >>           |
  1148.  
  1149.       -Program with dY/dX output (as real):
  1150.  
  1151.        <<  ->  X  <<    | function form
  1152.        X  IPOL          | calculates 2: d: and 1: Y:
  1153.        DROP             | drops Y:
  1154.        0  +             | d: (tagged) -> d (real)
  1155.        >>  >>           |
  1156.  
  1157.  !!!! Internal ROOT and DRAW commands don't accept tagged arguments; neither
  1158. do
  1159.  
  1160.  !!!! [SOLV] and [INTG]!
  1161.  
  1162.  
  1163. [CFIT]  CURVE FITTING
  1164. =====================
  1165.  
  1166. INPUT:    none
  1167.  
  1168. OUTPUT:   1: Correlation
  1169.  
  1170. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1171.           "Wrong ΣDAT Size"  ΣDAT size is different from { n 2 }
  1172.  
  1173. [CFIT] fits the data points from the 'ΣDAT' matrix. HP48 Curve Fitting
  1174. program offers only 4 base modles, but [CFIT] allows user modles:
  1175.  
  1176. For this example, we use the data points from the first example of [IPOL].
  1177.  
  1178. [CFIT] -> | Curve Fitting Modles
  1179.            |LIN: B + f(X)*M = g(Y)
  1180.            |PWR: B * f(X)^M = g(Y)
  1181.            |
  1182.            |[LIN] [] [] [] [] [PWR]
  1183.  
  1184. [CFIT] proposes 2 base modles: LIN and PWR
  1185.   - f(X) can be ANY function of X like f(X)=COS(X)^2+SIN(X)^2
  1186.   - in definition of g(Y), the variable Y can only appear ONE time because
  1187.     Y is isolated by the internal [ISOL] command:
  1188.     f.e. g(Y)=SQRT(1+SQ(Y))
  1189.                          ^
  1190.  
  1191.            |[LIN]
  1192.  
  1193.            |Modle: LINFIT
  1194.            |B + f(X) *M= g(Y)
  1195.            |Enter Function f(X):
  1196.                              ^
  1197. Algebraic enter mode is activated. 1ALPHA in case of alpha mode. EDIT menu is
  1198. activated (-> [->STK] command).
  1199.  
  1200.            |'COSH(X) <ENTER>
  1201.  
  1202. Just pressing <ENTER> would mean that g(X)=X!
  1203.  
  1204.            |Modle: LINFIT
  1205.            |B + f(X) *M= g(Y)
  1206.            |Enter Function g(Y):
  1207.                              ^
  1208.            |' <ENTER>
  1209.  
  1210. Pressing <ENTER> without entering any function element means that g(Y)=Y.
  1211.  
  1212.            |Computing LR-Elements
  1213.  
  1214.            |Enter ΣLINE Name:
  1215.  
  1216. ALPHA mode is activated. You can enter a function name for the curve.
  1217.  
  1218.            |APRX <ENTER>
  1219.  
  1220.            |Defining ΣLINE FCN
  1221.  
  1222.            1: Correlation:
  1223.               .999999996453
  1224.  
  1225. Test: 0.5 [APRX]  ->  1.12739143401
  1226.       0.5 [IPOL]  ->  1.12724112612
  1227.       0.5 [COSH]  ->  1.12762596521
  1228.  
  1229.  
  1230. [TRANS]  TRANSFORMING COORDINATES
  1231. =================================
  1232.  
  1233. INPUT:    none
  1234.  
  1235. OUTPUT:   none   
  1236.  
  1237. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1238.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1239.  
  1240. [TRANS] transforms data points from the 'ΣDAT' matrix:
  1241.  
  1242. [[ .. .. ]       [[ .. .. ]
  1243.  [ Xn Yn ]   ->   [ f(Xn,Yn,an,rn) g(Xn,Yn,an,rn) ]
  1244.  [ .. .. ]]       [ .. .. ]]
  1245.  
  1246. 'ΣDAT' PURGE
  1247. [DIFF]
  1248. [Y=SF(xy)dx] -> |'TAN(l) <ENTER>        (lambda: [right-shift] [NXT])
  1249.                  | 0 <SPACE> -1 <ENTER>  X0=0 and Y0=-1
  1250.                  | .1 <ENTER>            dH=.1
  1251.                  | .1 <ENTER>            dS=.1=dH (every point is stored)
  1252.                  |             </\>      algorithm able to compute l (lambda)
  1253.                  | 63 <ENTER>            63 points
  1254.  
  1255. [TRANS] -> |Enter X-Transformation
  1256.            |X1=f(X,Y,a,r)
  1257.  
  1258. !!!! a = ATAN(Y/X)            [right-shift] [A]
  1259. !!!! r = SQRT(SQ(X)+SQ(Y))    [right-shift] [R]
  1260. !!!! [X Y] = cartesian coordinates
  1261. !!!! [a r] = polar coordinates
  1262.  
  1263. Algebraic enter mode is activated. 1ALPHA in case of alpha mode. EDIT menu
  1264. is activated (-> [->STK] command).
  1265.  
  1266.             |'X*SIN(2*a) <ENTER>     a, Alpha
  1267.  
  1268. Just typing <ENTER> would mean that X1=X!
  1269.  
  1270.             |Enter Y-Transformation
  1271.            |Y1=g(X,Y,a,r)
  1272.  
  1273.             |'Y*SIN(2*a) <ENTER>     a, Alpha
  1274.  
  1275. Just typing <ENTER> would mean that Y1=Y!
  1276.  
  1277.             |Transforming (X,Y)
  1278.  
  1279. Data points are transformed and drawn as a scale curve.
  1280.  
  1281.  
  1282. [REVΣ]  REVERSING ΣDAT MATRIX
  1283. ===============================
  1284.  
  1285. INPUT:    none
  1286.  
  1287. OUTPUT:   none   
  1288.  
  1289. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1290.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1291.  
  1292. ACTION:   reverses 'ΣDAT' matrix
  1293.  
  1294. EXAMPLE:  [[ 1 1 ]    [REVΣ]   [[ 4 8 ]
  1295.             [ 2 4 ]               [ 3 6 ]
  1296.             [ 3 6 ]               [ 2 4 ]
  1297.             [ 4 8 ]]              [ 1 1 ]]
  1298.  
  1299.  
  1300. [ORDΣ]  ORDERING ΣDAT MATRIX
  1301. ==============================
  1302.  
  1303. INPUT:    none
  1304.  
  1305. OUTPUT:   none   
  1306.  
  1307. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1308.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1309.  
  1310. ACTION:   orders 'ΣDAT' matrix (X-column in GROWING order; Xn > Xn-1)
  1311.                                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  1312. EXAMPLE:  [[  1 -2 ]   [ORDΣ]   [[ -9  2 ]
  1313.             [  6  7 ]              [  1 -2 ]
  1314.             [  3  4 ]              [  3  4 ]
  1315.             [ -9  2 ]]             [  6  7 ]]
  1316.  
  1317.  
  1318. [DRWΣ]  DRAWING ΣDAT MATRIX (autoscaled)
  1319. ==========================================
  1320.  
  1321. INPUT:    none
  1322.  
  1323. OUTPUT:   none   
  1324.  
  1325. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1326.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1327.  
  1328. ACTION:   erases PICT and draws a scatter plot of 'ΣDAT' (AUTOSCALED)
  1329.           autoscaled => ΣMIN=PMIN & ΣMAX=PMAX
  1330.                          ^^^^^^^^^^   ^^^^^^^^^^
  1331.  
  1332. [SCLΣ]  DRAWING ΣDAT MATRIX (scale plot)
  1333. ==========================================
  1334.  
  1335. INPUT:    none
  1336.  
  1337. OUTPUT:   none   
  1338.  
  1339. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1340.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1341.  
  1342. ACTION:   erases PICT and draws a SCALE 'ΣDAT' plot
  1343.                                    ^^^^^
  1344.  
  1345. [LINΣ]  CONNECTING SCATTERED POINTS BY LINES
  1346. =============================================
  1347.  
  1348. INPUT:    none
  1349.  
  1350. OUTPUT:   none   
  1351.  
  1352. ERROR:    "Bad ΣDAT Data"    ΣDAT either doesn't exist or is not a matrix
  1353.           "Wrong ΣDAT Size"  ΣDAt size is different from { n 2 }
  1354.  
  1355. ACTION:   uses current plot parameters to connect 'ΣDAT' data points by lines
  1356.  
  1357. EXAMPLE:  [DRWΣ] [LINΣ] or [SCLΣ] [LINΣ]
  1358.  
  1359.  
  1360. BLOC DEFINITIONS
  1361. ================
  1362.  
  1363. NBR   TYPE                      ACTION                                  E  P
  1364.  
  1365.   0*  NULL ENTRY                E0=0                                     -  -
  1366.   1   ABSOLUTE VALUE             E0=ABS(E1)                              1  0
  1367.   2   SIGN                       E0=SIGN(E1)                             1  0
  1368.   3   NEGATIVE VALUE             E0=-E1                                  1  0
  1369.   4   SIGN TRANFER               E0=E1*SIGN(E2)                          2  0
  1370.   5   CLIP NEGATIVE              E0=IFTE(E1>0,E1,0)                      1  0
  1371.   6   CLIP POSITIVE              E0=IFTE(E1>0,0,E1)                      1  0
  1372.   7   FREE SPACE                 E0= * [see below]                       1  2
  1373.   8   LIMIT                      E0= * [see below]                       1  2
  1374.   9   SCALE                      E0= * [see below]                       1  3
  1375.  10   PHASE                     E0= * [see below]                       1  3
  1376.  11   RELAY 1                    E0=IFTE(E1>=0,E2,E3)                    3  0
  1377.  12   RELAY 2                    E0=IFTE(E1>0,E2,0)                      2  0
  1378.  13   MINIMUM                    E0=MIN(E1,E2)                           2  0
  1379.  14   MAXIMUM                    E0=MAX(E1,E2)                           2  0
  1380.  15   ADDITION 2                 E0=E1+E2                                2  0
  1381.  16   ADDITION 3                 E0=E1+E2+E3                             3  0
  1382.  17   MULTIPLICATION             E0=E1*E2                                2  0
  1383.  18   DIVISION                   E0=E1/E2                                2  0
  1384.  19   ADDITION CONSTANT          E0=E1+P1                                1  1
  1385.  20   MULTIPLICATION CONSTANT   E0=E1*P1                         1  1
  1386.  21   ADD+MUL 2                  E0=E1*P1+E2*P2                          2  2
  1387.  22   ADD+MUL 3                 E0=E1*P1+E2*P2+E3*P3             3  3
  1388.  23*                                                      
  1389.  24*
  1390.  25   INVERSE                    E0=INV(E1)                              1  0
  1391.  26   SQUARE                     E0=SQ(E1)                               1  0
  1392.  27   SQUARE ROOT                E0=SQRT(E1)                             1  0
  1393.  28   POWER                      E0=E1^E2                                2  0
  1394.  29   POLYNOM                    E0=P1+P2*E1+P3*E1^2                     1  3
  1395.  30   COMMON LOGARITHM           E0=P1*LOG(E1+P2)+P3                     1  3
  1396.  31   COMMON EXPONENTIAL        E0=P1*ALOG(E1*P2)+P3                     1  3
  1397.  32   NATURAL LOGARITHM          E0=P1*LN(E1+P2)+P3                      1  3
  1398.  33   NATURAL EXPONENTIAL       E0=P1*EXP(E1*P2)+P3                      1  3
  1399.  34*
  1400.  35*
  1401.  36   SINE                       E0=P1*SIN(E1*P2+P3)                     1  3
  1402.  37   COSINE                     E0=P1*COS(E1*P2+P3)                     1  3
  1403.  38   TANGENT                    E0=P1*TAN(E1*P2+P3)                     1  3
  1404.  39   ARC SINE                   E0=P1*ASIN(E1*P2+P3)                    1
  1405.  3
  1406.  40   ARC COSINE         E0=P1*ACOS(E1*P2+P3)                    1  3
  1407.  41   ARC TANGENT                E0=P1*ATAN(E1*P2+P3)                    1  3
  1408.  42   SINE HYPERBOLIC            E0=P1*SINH(E1*P2+P3)                    1
  1409.  3
  1410.  43   COSINE HYPERBOLIC          E0=P1*COSH(E1*P2+P3)                    1  3
  1411.  44   TANGENT HYPERBOLIC        E0=P1*TANH(E1*P2+P3)                     1  3
  1412.  45   ARC SINE HYPERBOLIC       E0=P1*ASINH(E1*P2+P3)                    1  3
  1413.  46   ARC COSINE HYPERBOLIC     E0=P1*ACOSH(E1*P2+P3)                    1  3
  1414.  47   ARC TANGENT HYPERBOLIC    E0=P1*ATANH(E1*P2+P3)                    1  3
  1415.  48*
  1416.  49*
  1417.  50   INTEGRATION 1             E0=P1+Integral[E1*P2]dt                  1  2
  1418.  51   INTEGRATION 2              E0=P1+Integral[E1*P2+E2*P3]dt           2  3
  1419.  52   LIMIT INTEGRATION         E0=P1+Integral[E1]dt,P2<=E0<=P3         1  3
  1420.  53   DERIVATIVE ** [see below]  E0=dE1/dt                               1  0
  1421.  54*
  1422.  55*
  1423.  56   RANDOM                     E0=RAND                                 0  0
  1424.  57   CONSTANT                   E0=P1                                   0  1
  1425.  58   QUIT                       quit if E1>E2                           2  0
  1426.  59*
  1427.  60   NULL                       E0=0                                    0  0
  1428.  61*
  1429.  62*
  1430.  63*
  1431.  64*
  1432.  65*
  1433.  66*
  1434.  67*
  1435.  68*
  1436.  69*
  1437.  70*
  1438.  71*
  1439.  72*
  1440.  73*
  1441.  74*
  1442.  75*
  1443.  76*
  1444.  77*
  1445.  78*
  1446.  79*
  1447.  80*
  1448.  81*
  1449.  82*
  1450.  83*
  1451.  84*
  1452.  85*
  1453.  86*
  1454.  87*
  1455.  88*
  1456.  89*
  1457.  90*
  1458.  91*
  1459.  92*
  1460.  93*
  1461.  94*
  1462.  95*
  1463.  96*
  1464.  97*
  1465.  98*
  1466.  99*
  1467. 100*  CURRENT TIME               E0=current time                         0  0
  1468.  
  1469.  nn*  undefined block type
  1470.   0*  can only be used to determine a null entry (En=0) in entry list
  1471. 100*  can only be used as time input
  1472.  
  1473. ** Block 53: derivative through the last 3 points
  1474.  
  1475.    Note: - Input E---[D>---O Output
  1476.            O=dE/dt
  1477.             
  1478.          - Input E---[I>---[D>---O Output
  1479.            O is NOT equal to E for algorithm reasons:
  1480.             
  1481.            TIME t   INPUT E   INTEGRAL I   OUTPUT O
  1482.             tn        En         In          On-1 (using In-3, In-2 and In-1)
  1483.             tn+1      En+1       In+1        On   (using In-2, In-1 and In)
  1484.  
  1485.            On(tn+1)=En(tn)! 
  1486.  
  1487. *** > 100   USER DEFINED BLOCKS
  1488.  
  1489.  
  1490. Block 7
  1491. -------
  1492.  
  1493.           ^                ^             /                  ^          
  1494.           |                |            /         \         |          
  1495.           |        /       |       1:1 /           \ 1:1    |          
  1496.           |   1:1 /        |          /             \       |          
  1497.     P1    |      /         |  P1     /               \      |P1        
  1498. ----:=====|=====:--->    --|--:=====:-------->    ----:=====|=:-------> 
  1499.    /      |    P2          | /     P2                 P2    |  \       
  1500.   /       |                |/                               |   \      
  1501.  / 1:1    |                / 1:1                            |1:1 \     
  1502. /         |               /|                                |     \    
  1503.           |                |                                |      \   
  1504.  
  1505.        P1 < P2                 P1 < P2                   P1 > P2
  1506.  
  1507.  
  1508. Block 8
  1509. -------
  1510.  
  1511.         P2-    ------      ^                                ^          
  1512.           |   /          P2-      ------------    -------   - -P2      
  1513.           |  / 1:1         |     /                       \  |          
  1514.           | /              |    / 1:1                 1:1 \ |          
  1515.       P1  |/               |   /                           \|   P1     
  1516. ------:---|----:---->    ---P1-                   ------:---|----:----> 
  1517.          /|   P2           |                            P2  |\         
  1518.     1:1 / |                | P1                             | \        
  1519.        /  |              --|--:---:---------->              |  \ 1:1   
  1520. -------   -P1              |     P2                         |   \      
  1521.           |                |                            -P1 -    ------
  1522.  
  1523.        P1 < P2                  P1 < P2                  P1 > P2
  1524.        
  1525.  
  1526. Block 9
  1527. -------
  1528.                                  P2>0
  1529.   ^                          <------->                      ^          
  1530.   |            ------        P1    |                        |          
  1531.   - P3        /          ====:-----|-:------->    --------- - P3       
  1532.   |          /                \    | P1+P2                 \|         
  1533.   |         / P3:P2            \   |                        \          
  1534.   |        /                    \  |                        |\ P3:P2    
  1535.   |       /                P3:P2 \ |                        | \        
  1536.   |      /                        \|                  P1+P2 |  \       
  1537. ==|=====:------:---->              \              --------:-|---:=====>
  1538.   |     P1   P1+P2                 |\                       |  P1      
  1539.   |     <------>                 P3- ---------            <----->      
  1540.           P2>0                                              P2<0
  1541.  
  1542.  
  1543. Block 10
  1544. --------
  1545.        
  1546.        ^
  1547.        |
  1548.     ---|P3---------
  1549.    |   |           |
  1550.    |   |           |
  1551.    |   |           |
  1552. ===:---|-----------:===>
  1553.    P1  |          P2
  1554.        |
  1555.  
  1556. P1 must be < than P2!
  1557.